package com.fourforfo.fourmall.product.dao;

import com.fourforfo.fourmall.product.entity.CategoryEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 商品三级分类
 * 
 * @author fourforfo
 * @email fourforfo@gmail.com
 * @date 2022-06-15 21:04:46
 */
@Mapper
public interface CategoryDao extends BaseMapper<CategoryEntity> {

	@Select("SELECT @id AS cat_id, (SELECT @id := parent_cid FROM pms_category WHERE cat_id = @id) AS parent_cid \n" +
			" FROM (SELECT @id := #{catelogId}) vars, pms_category WHERE @id <> 0")
	@Results({
			@Result(id=true,column="cat_id",property="catId")
	})
	List<CategoryEntity> getCatelogPathById(Long catelogId);
}
